package com.itheima.tezheng;

import java.util.concurrent.locks.ReentrantLock;

public class Demo01 {

    public static void main(String[] args) throws InterruptedException {
        Xiaolu xiaolu = new Xiaolu();
        Xiaotong xiaotong = new Xiaotong();
        Thread t1 = new Thread(xiaolu);
        Thread t2 = new Thread(xiaotong);
        t2.start();
        Thread.sleep(1000);
       t1.start();

    }
}
class Money{
    public static volatile int count=100000;
}
class Xiaolu implements Runnable{

    @Override
    public void run() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Money.count=Money.count-1000;
        System.out.println("买了一个终极皮肤");
    }
}
class Xiaotong implements Runnable{
private  Object object= new Object();
private ReentrantLock lock= new ReentrantLock();
    @Override
    public  void run() {
        while (true){
          //  synchronized (object) {
           // lock.lock();
            if(Money.count==100000){

            }else {
                System.out.println("妈呀,谁动了我的钱 ,分手");
                return;
            }
           // lock.unlock();
            //  }

        }
    }

    /*public synchronized void chakanqian() {

    }*/
}
